import {tpl} from "../wechat-lib/utils"

export default async (ctx,next) => {
    const message = ctx.msgJson;
    let content = null;
    const {MsgType} = message;
    if(MsgType === "text"){
        content = "得来联盟"
    }else if(MsgType === "image"){
        content = {
            type:'image',
            mediaId: message.MediaId
        }
    }else if(MsgType === "voice"){
        content = {
            type:'voice',
            mediaId: message.MediaId
        }
    }else if(MsgType === "video"){
        content = {
            type:'video',
            mediaId: message.MediaId
        }
    }else if (MsgType === 'location') {
        content = message.Location_X + ' : ' + message.Location_Y + ' : ' + message.Label
    }else if (MsgType === 'link') {
        content = [{
          title: message.Title,
          description: message.Description,
          picUrl: 'http://mmbiz.qpic.cn/mmbiz_jpg/xAyPZaQZmH09wYBjskFEQSoM4te0SnXR9YgbJxlDPVPDZtgLCW5FacWUlxFiaZ7d8vgGY6mzmF9aRibn05VvdtTw/0',
          url: message.Url
        }]
      };

    return tpl(content,message);
}